package com.breaking.second.activity.pager.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewbinding.ViewBinding;

import com.breaking.second.utils.ViewBindingUtil;

import lombok.Getter;

@Getter
public abstract class BaseAdapter<T extends ViewBinding> extends RecyclerView.Adapter<BaseAdapter.ViewHolder> {

    public final Context context;

    public BaseAdapter(Context context) {
        this.context = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ViewBinding viewBinding = ViewBindingUtil.inflate(getClass(), LayoutInflater.from(context), parent, false);
        return new ViewHolder(viewBinding.getRoot());
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        T binding = ViewBindingUtil.bind(getClass(), holder.itemView);
        onBindViewHolder(binding, position);
    }

    public void onBindViewHolder(T binding, int position) {

    }

    @Override
    public int getItemCount() {
        return 0;
    }
    public static class ViewHolder extends RecyclerView.ViewHolder {
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}

